home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / thor / multiupload.thor < prev    next >
Text File  |  1996-11-10  |  5KB  |  225 lines

  1. /* MultiUpload.thor by Troels Walsted Hansen
  2. ** $VER: MultiUpload.thor v2.00 (01.11.94)
  3. **
  4. ** An ARexx script that'll make it easier to upload one file to
  5. ** many BBSs.  Supports (AmiNet) filename.readme description files.
  6. ** If no .readme file is around, the script will attempt to obtain
  7. ** a short description from the filecomment of the file.
  8. **
  9. ** New: · filecomment reading added by request :-)
  10. **      · This version is only for THOR v2.0 or higher.
  11. */
  12.  
  13. options results
  14.  
  15. /* needs THOR and bbsread.library functions */
  16.  
  17. p = ' ' || address() || ' ' || show('P',,)
  18. thorport = pos(' THOR.',p)
  19.  
  20. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  21. else
  22. do
  23.     say 'No THOR port found!'
  24.     exit 10
  25. end
  26.  
  27. if ~show('p', 'BBSREAD') then
  28. do
  29.     address command
  30.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  31.         "WaitForPort BBSREAD"
  32. end
  33.  
  34. drop EVENT.
  35. EVENT.FILEDESCR = ""
  36.  
  37. /* main stuff */
  38.  
  39. address(bbsread)
  40. GETGLOBALDATA STEM GLOBALDATA
  41.  
  42. address(thorport)
  43. THORTOFRONT
  44. REQUESTFILE TITLE '"Select file to upload:"' ID '"'GLOBALDATA.UPLOADPATH'"' FP PAT '"#?"'
  45. if(rc ~= 0) then exit
  46.  
  47. EVENT.LOCALFILE = result
  48. lastchar = right(EVENT.LOCALFILE,1)
  49.  
  50. if(lastchar = "/" | lastchar = ":" | EVENT.LOCALFILE = "") then
  51. do
  52.     REQUESTNOTIFY TEXT '"No file selected!"' BT '"_Ok"'
  53.     exit
  54. end
  55.  
  56. /* check filename length here!!!
  57. GETBBSTYPEDATA stem BBSTYPEDATA
  58. if(lenght(EVENT.LOCALFILE) > BBSTYPEDATA.FILENAMELEN) then
  59. do
  60.     REQUESTSTRING TITLE '"Reduce number of characters in filename to 'BBSTYPEDATA.FILENAMELEN||"' ID '"'EVENT.LOCALFILE'"' BT '"_Ok|_Cancel"' MAXCHARS BBSTYPEDATA.FILENAMELEN
  61.     if(rc ~= 0) then exit
  62.     else EVENT.FILENAME = result
  63. end
  64. */
  65.  
  66. posi = lastpos("/",EVENT.LOCALFILE)
  67. if(posi = 0) then posi = lastpos(":",EVENT.LOCALFILE)
  68. EVENT.FILENAME = substr(EVENT.LOCALFILE,posi+1)
  69.  
  70. readmefile = substr(EVENT.LOCALFILE, 1, lastpos(".",EVENT.LOCALFILE))||"readme"
  71.  
  72. if exists(readmefile) then do
  73.     call open(ReadMe, readmefile)
  74.  
  75.     do while(~eof(ReadME) & EVENT.FILEDESCR = "")
  76.         Line = readln(ReadMe)
  77.         if(upper(substr(Line,1,6)) = "SHORT:") then EVENT.FILEDESCR = strip(substr(Line,8), B)
  78.     end
  79.  
  80.     call close(ReadMe)
  81. end
  82. else drop readmefile
  83.  
  84. if(EVENT.FILEDESCR = "") then
  85. do
  86.     address command 'list '||'"'||EVENT.LOCALFILE||'"'||' lformat="%C" >t:TempFilecommentFile'
  87.     call open(tfh,"t:TempFilecommentFile", R)
  88.         EVENT.FILEDESCR = readln(tfh)
  89.     call close(tfh)
  90.  
  91.     address command "delete >nil: t:TempFilecommentFile"
  92. end
  93.  
  94. if(EVENT.FILEDESCR = "") then
  95. do
  96.     REQUESTSTRING TITLE '"'||'Enter description for '|| EVENT.FILENAME||'"' BT '"_Ok|_Cancel"' MAXCHARS 40
  97.     EVENT.FILEDESCR = result
  98.     if(rc ~= 0) then exit
  99. end
  100.  
  101. REQUESTNOTIFY TEXT '"Do you wish to upload to BBSs from a list?"' BT '"_Yes|_No"'
  102.  
  103. if(result = 0) then
  104. do
  105.     REQUESTNOTIFY TEXT '"Enable private to conference uploading?"' BT '"_Yes|_No"'
  106.     AskForConfname = result
  107.  
  108.     address(bbsread)
  109.  
  110.     GETBBSLIST stem BBSLIST
  111.     if(rc ~= 0) then
  112.     do
  113.         address(thorport)
  114.         REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  115.         exit 5
  116.     end
  117.  
  118.     address(thorport)
  119.  
  120.     REQUESTLIST instem BBSLIST outstem USERBBSLIST title '"Select BBSs:"' DRAGSELECT MULTISELECT SIZEGADGET
  121.     if(rc ~= 0) then break
  122.     else bbs = result
  123.  
  124.     do i=1 to USERBBSLIST.COUNT
  125.         if(AskForConfname) then
  126.         do
  127.             address(bbsread)
  128.                 GETCONFLIST '"'USERBBSLIST.i'"' CONFLIST
  129.             if(rc ~= 0) then
  130.             do
  131.                 address(thorport)
  132.                 REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  133.                 exit 5
  134.             end
  135.  
  136.             address(thorport)
  137.  
  138.             REQUESTLIST instem CONFLIST title '"Select conference at ' || USERBBSLIST.i || ':' || '"' SIZEGADGET
  139.             if(rc ~= 0) then break
  140.             else EVENT.CONFERENCE = result
  141.         end
  142.         else drop EVENT.CONFERENCE
  143.  
  144.         address(bbsread)
  145.  
  146.         if(readmefile ~= "READMEFILE") then
  147.         do
  148.             UNIQUEMSGFILE bbsname '"'USERBBSLIST.i'"' stem UNIQUEFILE
  149.             if(rc ~= 0) then
  150.             do
  151.                 address(thorport)
  152.                 REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  153.                 exit
  154.             end
  155.  
  156.             address command 'copy >nil: ' || '"' || readmefile || '"' || ' TO ' || UNIQUEFILE.NAME
  157.             EVENT.DETAILEDFILEDESCR = UNIQUEFILE.FILEPART
  158.         end
  159.  
  160.         WRITEBREVENT bbsname '"'USERBBSLIST.i'"' event 5 stem EVENT
  161.         if(rc ~= 0) then
  162.         do
  163.             address(thorport)
  164.             REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  165.             exit 5
  166.         end
  167.         else
  168.         do
  169.             address(thorport)
  170.             PACKEVENTS '"'USERBBSLIST.i'"'
  171.         end
  172.     end
  173. end
  174. else
  175. do
  176.     REQUESTFILE TITLE '"Select MultiUpload list file:"' ID '"THOR:Rexx/PostingLists"' FP
  177.     configfile = result
  178.     lastchar = right(configfile,1)
  179.     if(rc~=0 | lastchar = "/" | lastchar = ":" | configfile = "") then exit
  180.  
  181.     call open(cf, configfile, R)
  182.  
  183.     do forever
  184.         call readln(cf)
  185.         bbs = substr(readln(cf),6)
  186.         if(bbs = "") then break
  187.         EVENT.CONFERENCE = substr(readln(cf),7)
  188.         if(EVENT.CONFERENCE = "") then drop EVENT.CONFERENCE
  189.  
  190.         address(bbsread)
  191.  
  192.         if(readmefile ~= "READMEFILE") then
  193.         do
  194.             UNIQUEMSGFILE bbsname '"'bbs'"' stem UNIQUEFILE
  195.             if(rc ~= 0) then
  196.             do
  197.                 address(thorport)
  198.                 REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  199.                 exit
  200.             end
  201.  
  202.             address command 'copy >nil: ' || '"' || readmefile || '"' || ' TO ' || UNIQUEFILE.NAME
  203.             EVENT.DETAILEDFILEDESCR = UNIQUEFILE.FILEPART
  204.         end
  205.  
  206.         WRITEBREVENT bbsname '"'bbs'"' event 5 stem EVENT
  207.         if(rc ~= 0) then
  208.         do
  209.             address(thorport)
  210.             REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  211.             exit 5
  212.         end
  213.         else
  214.         do
  215.             address(thorport)
  216.             PACKEVENTS '"'bbs'"'
  217.         end
  218.     end
  219.  
  220.     call close(cf)
  221. end
  222.  
  223. RESCAN
  224. exit
  225. k